/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author YDZ
 */
import { defHttp } from '/@/utils/http/axios';
import { useGlobSetting } from '/@/hooks/setting';
import { BasicModel, Page } from '../model/baseModel';
import { UploadApiResult } from '../sys/upload';
import { UploadFileParams } from '/#/axios';

const { ctxPath, adminPath } = useGlobSetting();

export interface PmMaterialMain extends BasicModel<PmMaterialMain> {
  mcode?: string; // 材料编码
  mname?: string; // 材料名称
  mstd?: string; // 规格型号
  munit?: string; // 单位
}

export const pmMaterialMainList = (params?: PmMaterialMain | any) =>
  defHttp.get<PmMaterialMain>({ url: adminPath + '/material/main/pmMaterialMain/list', params });

export const pmMaterialMainListData = (params?: PmMaterialMain | any) =>
  defHttp.post<Page<PmMaterialMain>>({
    url: adminPath + '/material/main/pmMaterialMain/listData',
    params,
  });

export const pmMaterialMainForm = (params?: PmMaterialMain | any) =>
  defHttp.get<PmMaterialMain>({ url: adminPath + '/material/main/pmMaterialMain/form', params });

export const pmMaterialMainSave = (params?: any, data?: PmMaterialMain | any) =>
  defHttp.postJson<PmMaterialMain>({
    url: adminPath + '/material/main/pmMaterialMain/save',
    params,
    data,
  });

export const pmMaterialMainImportData = (
  params: UploadFileParams,
  onUploadProgress: (progressEvent: ProgressEvent) => void,
) =>
  defHttp.uploadFile<UploadApiResult>(
    {
      url: ctxPath + adminPath + '/material/main/pmMaterialMain/importData',
      onUploadProgress,
    },
    params,
  );

export const pmMaterialMainDelete = (params?: PmMaterialMain | any) =>
  defHttp.get<PmMaterialMain>({ url: adminPath + '/material/main/pmMaterialMain/delete', params });

export const pmMaterialMainBatchDel = (params?: PmMaterialMain | any) =>
  defHttp.get<PmMaterialMain>({
    url: adminPath + '/material/main/pmMaterialMain/batchDelete',
    params,
  });
